package com.cxyjy.common.util;

import lombok.Data;

/**
 * @Author: jony
 * @Date : 2024/11/6 09:49
 * @VERSION v1.0
 */
@Data
public class JResponse<T> {
    private int code;

    private String message;

    private T data;

    /**
     * 构造函数
     * @param code 状态码
     * @param message 操作反馈信息，如登录成功
     * @param data 向前端传的数据
     */
    public JResponse(int code, String message, T data){
        this.code=code;
        this.message=message;
        this.data=data;
    }
    public JResponse(int code, T data){
        this(code,ResultCode.find(code).getMessage(),data);
    }

    public JResponse(int code, String message){
        this(code,message,null);
    }

    public JResponse(int code){
        this(ResultCode.find(code));
    }
    public JResponse(ResultCode resultCode){
        this(resultCode.getCode(),resultCode.getMessage());
    }


}
